package com.google.code.netbuilder.dal.services;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import javax.xml.crypto.Data;

import com.google.code.netbuilder.dal.providers.*;

public abstract class DAOServis 
{
	private static DAOServis servis = null;
	
	public abstract ICableProvider getCabelProvider();
	public abstract ICableWireProvider getCableWireProvider();
	public abstract IEquipmentPortProvider getEquipmentPortProvider();
	public abstract IEquipmentProvider getEquipmentProvider();
	public abstract IEquipmentVersion getEquipmentVersion();
	public abstract IPortProvider getPortProvider();
	public abstract IWireProvider getWireProvider();
	public abstract IWireVersion getWireVersion();
	
	public final static DAOServis getInstanse()
	{
		Properties properties = new Properties();
		FileInputStream in = null;	
		
		try {
			in = new FileInputStream(new File("properties.property"));
			properties.load(in);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			if (in!=null)
				try {
					in.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		}
		
		String DBConnectionType = properties.getProperty("DBConnection");
		if (DBConnectionType.equals("JDBC"))
			return new JDBCServise();
		else if (DBConnectionType.equals("JPA"))
			return new JPAServise();
		return null;	
	}
}
